var data = {
    count:30,
    sum:20,
    sub:33,
}

function reducer(state = data , action = { type:'' , params : null }) {
    var newState = JSON.parse(JSON.stringify( state ));
    // 判断 action 的类型 执行不同的操作 然后去修改 state

    switch ( action.type ) {
        case 'ADD' :
        //* ----逻辑代码------
        newState.count += action.params;
        console.log('已经执行');
        return newState;

        //* ----逻辑代码------
        case 'DELETE' :
        newState.sum += action.params;
        console.log('已经执行');
        return newState;
            
        //* ----逻辑代码------
        case 'BIANJI' :
        newState.sub -= action.params;
        return newState;
        
        default: return state;
    }


    return newState;
}

export default reducer;